
int recursion(TreeNode* root)
{
    if(!root){
        return 0;
    }
    int left = recursion(root->left);
    if(left == -1){
        return -1;
    }
    int right = recursion(root->right);
    if(right == -1){
        return -1;
    }
    return abs(left-right) <= 1 ? max(left,right) + 1 : -1;
}

bool JudgeBlanceBinary(TreeNode* root)
{
    return recursion(root) != -1;
}